import router from '@/router'
import store from '@/store'

router.beforeEach(async(to, from, next) => {
  // 写法一
  const url = to.path
  const token = store.getters.token
  //   1.1 去登陆页
  if (token && (url === '/login' || url === '/')) {
    await store.commit('user/delUser')
  }
  next()
})
